home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 1 / Gold Medal Software Volume 1 (Gold Medal) (1994).iso / prog / actlib17.arj / BCTOOLS.ARJ / LISTFILE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-25  |  975 b   |  48 lines

  1. #include "bctools.h"
  2. #include <stdio.h>
  3. #include <conio.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6.  
  7.  
  8. /***
  9.  *
  10.  *  Function listfile :    display a file on screen with pause
  11.  *               after each screen.
  12.  *
  13.  ***/
  14.  
  15. int listfile( char *filename )
  16.  
  17. { FILE *fp;
  18.   char buffer[82];
  19.   int line;
  20.  
  21.   if (! (fp = fopen(filename,"rb")) ) return -2;
  22.  
  23.   window( 1, 1, 80, 25 );
  24.   clrscr();
  25.  
  26.   for ( line = 0; fgets(buffer, 81, fp); line ++ )
  27.       {
  28.     clreol();
  29.     cputs( buffer );
  30.     if ( line == 23 ) { gotoxy( 75, 25 );
  31.                             cputs( "<···>" );
  32.                 if ( getkey() == ESC ) return -1;
  33.                     gotoxy( 1, 25 ); clreol();
  34.                 line = 0;
  35.               }
  36.       }
  37.  
  38.   cputs( "\n\r" );
  39.   if ( line != 1 ) { gotoxy( 75, 25 );
  40.                      cputs( "<···>" );
  41.                      if ( getkey() == ESC ) return -1;
  42.              gotoxy( 1, 25 ); clreol();
  43.            }
  44.   fclose( fp );
  45.  
  46.   return 0;
  47. }
  48.